#include <stdio.h>
#include <stdbool.h>

#include "freertos.h"
#include "task.h"

#include "bms_monitor.h"
#include "bms_analysis.h"


// thread config
#define INFO_TASK_STACK_SIZE	512	
#define INFO_TASK_PRIORITY		1
#define INFO_TASK_PERIOD		  2000

static TaskHandle_t InfoTaskHandler = NULL;  

static bool FlagInfoPrintf = true;

static void BMS_InfoTaskEntry(void *paramter);
static void BMS_InfoPrintf(void);
static void BMS_InfoBatCapacityIndicator();

void BMS_InfoInit(void)
{
	BaseType_t res = xTaskCreate(BMS_InfoTaskEntry, 
															 "info",
															 INFO_TASK_STACK_SIZE,
															 NULL,
															 INFO_TASK_PRIORITY,
															 &InfoTaskHandler);
	if(res != pdPASS)
	{
		printf("Create Info Task Fail\r\n");
	}
}

static void BMS_InfoTaskEntry(void *paramter)
{
	while(1)
	{
		if(FlagInfoPrintf)
		{
			BMS_InfoPrintf();
		}
		
		// 点亮灯指示
		BMS_InfoBatCapacityIndicator();
		vTaskDelay(pdMS_TO_TICKS(INFO_TASK_PERIOD));
	}
}

static void BMS_InfoPrintf(void)
{
//	printf("Current = %f\r\n", BMS_MonitorData.BatteryCurrent);
//	printf("Current SOC = %f\r\n", BMS_AnalysisData.SOC);
//	for(int i = 0; i < 5; ++i)
//	{
//		printf("Cell [ %d ] vol = %f\r\n", BMS_MonitorData.CellData[i].CellVoltage);
//	}
}


void BMS_InfoBatCapacityIndicator()
{
	
}
